--Create database Cuestionarios;

USE [Cuestionarios]
GO
/****** Object:  Table [dbo].[Cuestionario]    Script Date: 23/09/2014 17:22:35 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Cuestionario](
	[IdCuestionario] [int] IDENTITY(1,1) NOT NULL,
	[Descripcion] [varchar](300) NOT NULL,
	[FechaCreacion] [datetime] NOT NULL,
	[CodigoArea] [varchar](3) NOT NULL,
	[Estado] [varchar](20) NOT NULL,
	[NumeroPreguntas] [int] NOT NULL,
	[CalificacionMaxima] [decimal](18, 0) NOT NULL,
	[CalificacionMinima] [decimal](18, 0) NOT NULL,
	[IdDocente] [int] NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[IdCuestionario] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Opcion]    Script Date: 23/09/2014 17:22:35 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Opcion](
	[IdOpcion] [int] IDENTITY(1,1) NOT NULL,
	[IdPregunta] [int] NOT NULL,
	[Descripcion] [varchar](300) NOT NULL,
	[Respuesta] [bit] NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[IdOpcion] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Pregunta]    Script Date: 23/09/2014 17:22:35 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Pregunta](
	[IdPregunta] [int] IDENTITY(1,1) NOT NULL,
	[CodigoTipo] [varchar](3) NOT NULL,
	[Enunciado] [varchar](500) NOT NULL,
	[CodigoCategoria] [varchar](3) NOT NULL,
	[CodigoArea] [varchar](3) NOT NULL,
	[Estado] [varchar](20) NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[IdPregunta] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[PreguntaCuestionario]    Script Date: 23/09/2014 17:22:35 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[PreguntaCuestionario](
	[IdCuestionario] [int] NOT NULL,
	[IdPregunta] [int] NOT NULL,
	[Calificacion] [decimal](18, 0) NOT NULL,
 CONSTRAINT [PK_PreguntaCuestionario] PRIMARY KEY CLUSTERED 
(
	[IdCuestionario] ASC,
	[IdPregunta] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[Recurso]    Script Date: 23/09/2014 17:22:35 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Recurso](
	[IdRecurso] [int] IDENTITY(1,1) NOT NULL,
	[Nombre] [varchar](300) NOT NULL,
	[CodigoTipo] [varchar](3) NOT NULL,
	[Uri] [varchar](300) NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[IdRecurso] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[RecursoPregunta]    Script Date: 23/09/2014 17:22:35 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[RecursoPregunta](
	[IdPregunta] [int] NOT NULL,
	[IdRecurso] [int] NOT NULL,
 CONSTRAINT [PK_RecursoPregunta] PRIMARY KEY CLUSTERED 
(
	[IdPregunta] ASC,
	[IdRecurso] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
